package file01;

import java.io.File;

/*
File类的构造方法：
File类的构造方法：不会检测传入的路径是否在硬盘上真实存在


     File(String pathname)
          pathname:路径名 既可以传相对路径，也可以传绝对路径
          通过将给定路径名字符串转换为抽象路径名来创建一个新 File 实例。
     File(String parent, String child)
          parent:父级路径  一般传入文件或文件夹前面的路径
          child :子级路径  一般传入文件或文件夹
          最终的路径就是将parent和child拼接的路径
          根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例。
     File(File parent, String child)
          根据 parent 抽象路径名和 child 路径名字符串创建一个新 File 实例。

 */
public class FileDemo01 {
    public static void main(String[] args) {
        //method01();
        //method02();
        File parent = new File("D:/java_vev/workspace/java-se/Project_JavaSE/Day22/");//将父级路径封装成一个File对象
        File file = new File(parent, "1.txt");
        System.out.println(file);//D:\java_vev\workspace\java-se\Project_JavaSE\Day22\1.txt

    }

    private static void method02() {
        File file = new File("D:/java_vev/workspace/java-se/Project_JavaSE/Day22/", "1.txt");
        System.out.println(file);//D:\java_vev\workspace\java-se\Project_JavaSE\Day22\1.txt

        File file2 = new File("D:/java_vev/workspace/", "java-se/Project_JavaSE/Day22/1.txt");
        System.out.println(file2);//D:\java_vev\workspace\java-se\Project_JavaSE\Day22\1.txt

        File file3 = new File("M:/java_vev/workspace/", "java-se/Project_JavaSE/Day22/1.txt");
        System.out.println(file3);//D:\java_vev\workspace\java-se\Project_JavaSE\Day22\1.txt

        File file4 = new File("D:/java_vev/", "java-se/Project_JavaSE/Day22/1.txt");
        System.out.println(file4);//D:\java_vev\workspace\java-se\Project_JavaSE\Day22\1.txt
    }

    private static void method01() {
        //java中的转义字符都是以/开头的：\n  换行
        System.out.println("\nab\nc");
        //System.out.println("\a"); //\a不是Java中的转义字符，因此解析不了
        System.out.println("\\a");  //  \\的含义，第一个\将第二个\转义为普通的\字符

        //File file = new File("D:\\java_vev\\workspace\\java-se\\Project_JavaSE\\Day22\\1.txt");
        File file = new File("D:/java_vev/workspace/java-se/Project_JavaSE/Day22/1.txt");
    }
}
